<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="service.*,pojo.*,dao.*,java.util.*"%>
    <%@page import="service.*,pojo.*,java.util.List" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div>
<h1>地址</h1>
请选择收货信息
<table border="1" >
<tr>
<td>选项</td><td>地址编号</td><td>收获人姓名</td><td>收货人地址</td>
<td>收货人电话</td><td>操作</td></tr>
<% 
Customer cu =(Customer)(session.getAttribute("c"));
CartService cservice=new CartService();
UserAddressService use=new UserAddressService ();
 List<UserAddress> list1=use.showUserAddress(cu.getC_name());
 for(int i=0;i<list1.size();i++){
	 UserAddress u=list1.get(i);
	%>
	 <tr>
	 <td><input type="radio" name="u_id" value="<%=u.getUid()%>"></td>
	 <td><%=u.getUid() %></td>
	 <td><%=u.getName()%></td>
     <td><%=u.getAddress() %></td>
     <td><%=u.getTel()%></td>
	 <td><a href="<%=request.getContextPath()%>/UserAddressServlet?method=up&uid=<%=u.getUid() %>">修改</a>
	 &nbsp;<a href="<%=request.getContextPath()%>/UserAddressServlet?method=del&uid=<%=u.getUid()%>">删除</a>
 	 </td></tr>
 <%}%>
 <tr>
 	<td colspan="6"><a href="addAddress.jsp?name=<%=cu.getC_name()%>">添加地址</a></td></tr>
</table>
</div>
<form action="<%=request.getContextPath()%>/OrderServlet?method=add">
<div>
<h1>订单</h1>
<table border="1">
<tr>
<td>登录人</td><td>商品编号</td><td>商品图片</td><td>商品名字</td>
<td>商品价格</td><td>商品数量</td><td>商品总价</td><td>操作</td></tr>
<% 
//用户选择获取的商品
String cids[]=request.getParameterValues("cc_id");
	for(String s:cids){
		int id=Integer.parseInt(s);
		CartService cs=new CartService();
		List<Cart> list=cs.getOneCart(id);
		for(int i=0;i<list.size();i++){
			Cart cart=list.get(i);
	 %>
	 <tr>
	 <td><%=cart.getC_name() %></td>
	 <td><%=cart.getP_id() %></td>
	 <td><img src="<%=cart.getP_image()%>" width="50px" height="25px"/></td>
	 <td><%=cart.getP_name() %></td>
	 <td><%=cart.getP_price() %></td>
	 <td><%=cart.getQuantity() %></td>
	 <td><%=cart.getAmount() %></td>
	 <td><a href="<%=request.getContextPath()%>/OrderServlet?method=del&pid=<%=cart.getP_id() %>">删除</a>
</td></tr>
 <%}
}%>
<h2>
<input type="submit" value="结算"/>:<a href="weixin.jsp">微信</a>或者<a href="zhifubao.jsp">支付宝</a>
</h2>
 </table>
</div>
</form>
</body>
</html>